<?php

/*
=====================================================
 Generic Toolbox - by Carl Wells
-----------------------------------------------------
-----------------------------------------------------
 Copyright (c) 2009 Carl Wells
=====================================================
 THIS IS COPYRIGHTED SOFTWARE
 PLEASE READ THE LICENSE AGREEMENT
=====================================================
 File: system/display/adminpromodisplay.class.php
-----------------------------------------------------
 Purpose: This file builds all visual aspects of the Admin Section.
 All browser output is managed by this file.
=====================================================
*/
class Categorydisplay extends Admindisplay
{
        
        
      
      
      function displayCurrentCategories(){
      	require_once("core/category.class.php");
     	$CATEGORY = new Category();
		$categories = $CATEGORY->getCategories($_GET['sector']);
		$html = "<h2 class=\"adminHeader\">Current Categories - ";
		$html .= "<a href=\"index.php?act=addcategory&amp;sector=".$_GET['sector']."\">Add Categories</a></h2>";
		
      		foreach ($categories as $array){
      		$html .= "<div class=\"catSection\">";
      		$html .= "<p class=\"adminLink\">".$array['nameOfCategory']." ";
      		$html .= "<a href=\"index.php?act=categoryedit&amp;sectorId=".$array['sectorId']."&amp;id=".$array['id']."\">Edit Category <img src=\"../images/edit_blue_item.gif\" alt=\"Edit Category\" /></a> ";
      		$html .= "<a href=\"deletecategory.php?sectorId=".$array['sectorId']."&amp;id=".$array['id']."\" onclick=\"return confirmLink(this, 'delete ".$array['nameOfCategory']." from the system.')\">Delete Category <img src=\"../images/delete_blue_item.gif\" alt=\"Delete Category\" /></a></p>";
      		$html .= "<div class=\"catPromoSection\">";
      		$html .= "<p class=\"adminLink\"><a href=\"index.php?act=addpromotion&amp;sector=".$array['sectorId']."&amp;id=".$array['id']."\" >Add Promotion <img src=\"../images/add_blue_item.gif\" alt=\"Add Promotion\" /></a> ";
      		$html .= "<a href=\"index.php?act=editpromotions&amp;sector=".$array['sectorId']."&amp;id=".$array['id']."\" >Edit Promotions <img src=\"../images/edit_blue_item.gif\" alt=\"Edit Promotion\" /></a>  ";
      		$html .= "</p>";
      		$html .= "</div>";
      		$html .= "</div>";
        }
        
       
        echo ( $html );
      }
      
      
      function addCategory($sector){
      	$html = "<form method=\"post\" action=\"addcategory.php\" name=\"insertForm\"  enctype=\"multipart/form-data\">\n";
		// instantiate a Sector Object
			require_once ("core/category.class.php");
     		$CATEGORY = new Category();
     		$html .= "<input type=\"hidden\" name=\"sectorId\" value=\"".$sector."\"/>";
			$html .= "<table>";
			$html .= "<tr>";
        	
		    $html .= "<td>Name Of Category <input type=\"text\" name=\"editCategoryName\" value=\"\" size=\"30\" class=\"textfield\" tabindex=\"1\" /> <label for\"group\">Does this need group members? <input type=\"checkbox\" id=\"group\" name=\"group\" value=\"true\"></label></td>\n";
        
			$html .= "</tr>";
			
			$html .= "<tr>";
        	
		    $html .= "<td>Sub Category <input type=\"text\" name=\"SubCategoryName\" value=\"\" size=\"30\" class=\"textfield\" tabindex=\"2\" /> </td>\n";
        
			$html .= "</tr>";
			
			
			$html .= "<tr>";
			$html .= "<td><input type=\"submit\" value=\"Go\" /></td>\n";
			$html .= "</tr>";
			$html .= "</table>";
			$html .= "</form>\n";
			
	        echo $html;
      
      }
      
      
      function displayEditCategory($sectorId, $id){
      		$html = "<form method=\"post\" action=\"updatecategory.php\" name=\"insertForm\"  enctype=\"multipart/form-data\">\n";
		// instantiate a Sector Object
			require_once ("core/category.class.php");
     		$CATEGORY = new Category();
     
     
			$html .= "<input type=\"hidden\" name=\"db\" value=\"aramark\" />";
			$html .= "<input type=\"hidden\" name=\"table\" value=\"sectors\" />";
			$html .= "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
			$html .= "<input type=\"hidden\" name=\"sectorId\" value=\"".$sectorId."\" />";
	
			
			$categories = $CATEGORY->getIndividualCategory($id, $sectorId);

			$html .= "<table>";
			$html .= "<tr>";
        
			foreach ($categories as $array){
		        $html .= "<td>Name Of Category <input type=\"text\" name=\"editCategoryName\" value=\"".$array['nameOfCategory']."\" size=\"30\" class=\"textfield\" tabindex=\"1\" /></td>\n";
			}
        
			$html .= "</tr>";
			$html .= "<tr>";
			$html .= "<td><input type=\"submit\" value=\"Go\" /></td>\n";
			$html .= "</tr>";
			$html .= "</table>";
			$html .= "</form>\n";
			
	        echo $html;
      }
      
      
            
      
        
   	
}

?>